#ifndef QNETDEBUG_H
#define QNETDEBUG_H

#include <QObject>
#include <QString>
#include <QHostAddress>
#include <QUdpSocket>
#include <QDateTime>

class QNetDebug : public QObject
{
    Q_OBJECT
public:
    explicit QNetDebug(QObject *parent = nullptr);
    ~QNetDebug();

    // Initialize with server address and port
    bool init(const QString &serverAddress = "127.0.0.1", quint16 serverPort = 7777);

    // Main debug message sending method
    void kgWrite(const QString &message);

    // Additional methods with different log levels
    void info(const QString &message);
    void warning(const QString &message);
    void error(const QString &message);
    void debug(const QString &message);

    // Getters and setters
    QHostAddress serverAddress() const;
    void setServerAddress(const QHostAddress &address);

    quint16 serverPort() const;
    void setServerPort(quint16 port);

    QString applicationName() const;
    void setApplicationName(const QString &name);

    // Enable/disable timestamp in messages
    bool timestampEnabled() const;
    void setTimestampEnabled(bool enabled);

private:
    QUdpSocket *m_socket;
    QHostAddress m_serverAddress;
    quint16 m_serverPort;
    QString m_appName;
    bool m_timestampEnabled;

    // Internal method to format and send message
    void sendMessage(const QString &prefix, const QString &message);
};

#endif // QNETDEBUG_H
